import React, { Component } from "react";

export default class LifeCom extends Component {
  state = {
    count: 0,
  };
  render() {
    return (
      <div>
        <div>{this.state.count}</div>
        <button onClick={() => {this.setState({count: this.state.count + 1})}}>增加</button>
      </div>
    );
  }

  //添加声明周期的方法
  //componentDidMount  组件实例调用的该方法
  componentDidMount() {
    console.log(this);
    console.log("mount mount mount... ");
  }

  //组件将要卸载
  componentWillUnmount() {
    console.log("unmount unmount unmount");
  }

  //组件更新完成的生命周期
  componentDidUpdate() {
    console.log("update update update");
  }
}
